Skip to content

Conversation

@dom96
Copy link
Contributor

@dom96 dom96 commented Nov 19, 2025

This is something that we don't even have as an example for JS: a long-running Durable Object which streams data from a web socket.

This one listens to Bluesky's jetstream to grab events for each post on Bluesky. It then prints at most one every second.

Deployed to https://python-websocket-stream-consumer.runtime-playground.workers.dev.

@dom96 dom96 force-pushed the dominik/websocket-stream-consumer branch from 65a0905 to 8d5b904 Compare November 20, 2025 11:34
@dom96 dom96 force-pushed the dominik/websocket-stream-consumer branch 3 times, most recently from e77f8ed to 04bd250 Compare November 21, 2025 15:08
"""Handle WebSocket error event."""
print(f"WebSocket error: {event}")
self.connected = False
self.ctx.abort("WebSocket error occurred")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ctx.abort() behave well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should do, why wouldn't it? It restarts the DO.

Copy link
Contributor

@hoodmane hoodmane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM.

@dom96 dom96 force-pushed the dominik/websocket-stream-consumer branch from 04bd250 to 984758d Compare November 25, 2025 17:41
@dom96 dom96 merged commit c074858 into main Nov 25, 2025
6 of 7 checks passed
@hoodmane hoodmane deleted the dominik/websocket-stream-consumer branch November 25, 2025 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants